import 'package:flame/events.dart';
import 'package:flame/game.dart';
import 'package:hero_back/study/flutter_game_flame/day006/components/circle.dart';

import 'components/line.dart';
import 'components/polygon.dart';

class CollisionGame extends FlameGame with HasCollisionDetection, PanDetector {
  late Line line;
  late Circle circle;
  late Polygon polygon;

  @override
  Future<void> onLoad() async {
    circle = Circle(radius: 40, position: size / 2);
    line = Line(lineWidth: 80, position: size / 2 - Vector2(140, 0));
    polygon = Polygon(radius: 60, position: size / 2 + Vector2(140, 0));
    add(circle);
    add(line);
    add(polygon);
  }

  @override
  void onPanUpdate(DragUpdateInfo info) {
    line.position += info.delta.global;
  }
}
